package cn.mpq.payment.controller;

import cn.mpq.payment.common.Result;
import cn.mpq.payment.config.FastDFSClientWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/mxy/file")
public class FastDFSController {
    @Autowired
    private FastDFSClientWrapper dfsClient;

    // 上传图片
    @RequestMapping(value = "upload")
    public String upload(MultipartFile file) throws Exception {
        // 省略业务逻辑代码。。。
        String imgUrl = dfsClient.uploadFile(file);
        System.out.println(imgUrl);
        // 。。。。
        return imgUrl;
    }
    // 删除图片
    @RequestMapping(value = "delete")
    public Result delete(String fileUrl) throws Exception {
        // 省略业务逻辑代码。。。
        dfsClient.deleteFile("group1/M00/00/00/rBUAAlsOZ8uAUn_tAAEjePmpWso183.jpg");
        return new Result("0","删除成功");
    }
}
